import { axios } from "../utils/request";

const api = {
    Login: "/auth/login",
    Logout: "/logout",
    ForgePassword: "/auth/forge-password",
    Register: "/auth/register",
    twoStepCode: "/auth/2step-code",
    SendSms: "/account/sms",
    SendSmsErr: "/account/sms_err",
    // get my info
    UserInfo: "/sysUser/getUserInfo",
    UserMenu: "/sysMenu/user/list",
    LoginConfig: "/public/loginConfig",
    getDownloadUrl: "/auth/getDownloadUrl"
};
/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */
// 获取app下载链接
export function getDownloadUrl(parameter) {
    return axios({
        url: api.getDownloadUrl,
        method: "get",
        params: parameter
    });
}

export function login(parameter) {
    return axios({
        url: api.Login,
        method: "post",
        data: parameter
    });
}

export function getSmsCaptcha(parameter) {
    return axios({
        url: api.SendSms,
        method: "post",
        data: parameter
    });
}

export function getInfo() {
    return axios({
        url: api.UserInfo,
        method: "get",
        headers: {
            "Content-Type": "application/json;charset=UTF-8"
        }
    });
}

export function getCurrentUserNav(token) {
    return axios({
        url: api.UserMenu,
        method: "get",
        data: token
    });
}

export function logout() {
    return axios({
        url: api.Logout,
        method: "post",
        headers: {
            "Content-Type": "application/json;charset=UTF-8"
        }
    });
}

/**
 * get user 2step code open?
 * @param parameter {*}
 */
export function get2step(parameter) {
    return axios({
        url: api.twoStepCode,
        method: "post",
        data: parameter
    });
}

export function LoginConfig(token) {
    return axios({
        url: api.LoginConfig,
        method: "get",
        params: token
    });
}